package com.example.shouybl.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.shouybl.R;
import com.example.shouybl.bean.NewAward;
import com.example.shouybl.utils.ImageLoaderUtil;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * Created by Administrator on 2015/10/13.
 */
public class NewAwardAdapter extends AppBaseAdapter<NewAward> {
    private DisplayImageOptions options;
    public NewAwardAdapter(List<NewAward> list, Context context) {
        super(list, context);
        options= ImageLoaderUtil.getDefaultOptions();

    }

    @Override
    public ViewHolder getViewHolder(int position, View convertView, ViewGroup parent) {
        NewAward newAward=list.get(position);
        ViewHolder vh=ViewHolder.get(context,convertView,parent,R.layout.item_my_end_layout);
        ImageView ivIcon= (ImageView) vh.findViewById(R.id.iv_my_icon);
        TextView tvName= (TextView) vh.findViewById(R.id.tv_my_name);
        TextView tvRemain= (TextView) vh.findViewById(R.id.tv_my_remain);
        Button btnCunsume= (Button) vh.findViewById(R.id.btn_my_consume);

        ImageLoader.getInstance().displayImage(newAward.getIcon(),ivIcon,options);
        tvName.setText(newAward.getName());
        tvRemain.setText("剩余"+newAward.getRemain());
        btnCunsume.setText(newAward.getConsume()+"Q币");
        return vh;
    }
}
